<script>
    $(document).ready(function(){
        $("#produk_det").change(function(){
            var dta=$("#produk_dett").val();
            var dataString="";
            
            if(dta!=""){
                $.ajax({
                    type: "POST",
                    url: base_url+"main/produk/cari_stok/"+dta,
                    data: dataString,
                    cache: false,
                    success: function(html){
                        if(html==0)
                            $("#stok").html("Stok Habis");
                        else
                            $("#stok").html(html);
                        $("input[name=bnyk]").attr("class", 'validate[required, custom[integer],min[1],max['+html+']] text-input');
                        $("input[name=bnyk]").focus();
                    } 
                });
            }
            else{
                $("#stok").html("(Tentukan Pilihan terlebih dulu)");
            }
        })
        
        $("#1").click(function(){
            $("#22").hide();
            $("#33").hide();
            $("#11").fadeIn();
        })
   
        $("#2").click(function(){
            $("#11").hide();
            $("#33").hide();
            $("#22").fadeIn();
        })
        
        $("#3").click(function(){
            $("#11").hide();
            $("#22").hide();
            $("#33").fadeIn();
        })
        
    });
</script>
<?php
$lib_img = new images_thumb();
$lib_rupiah = new Format_rupiah();

$id_produk = $list_produk->id;
$nama_produk = $list_produk->nama_produk;
$warna = $list_produk->warna;
$disk = $list_produk->disk;
$harga = $list_produk->harga;
$keterangan = $list_produk->keterangan;

if ($disk <= 0)
    $harga = $lib_rupiah->rupiah($harga);
else {
    $sub = $harga - ($harga * $disk / 100);
    $harga = "<em style='text-decoration: line-through'> " . $lib_rupiah->rupiah($harga) . " </em> &nbsp;  " . $lib_rupiah->rupiah($sub);
}



$gambar1 = base_url() . "uploads/" . $list_produk->id . "/" . $lib_img->image($list_produk->image1);
$gambar11 = base_url() . "uploads/" . $list_produk->id . "/" . $list_produk->image1;

$gambar2 = base_url() . "uploads/" . $list_produk->id . "/" . $lib_img->image($list_produk->image2);
$gambar22 = base_url() . "uploads/" . $list_produk->id . "/" . $list_produk->image2;

$gambar3 = base_url() . "uploads/" . $list_produk->id . "/" . $lib_img->image($list_produk->image3);
$gambar33 = base_url() . "uploads/" . $list_produk->id . "/" . $list_produk->image3;
?>

<div class="twelve columns">

    <div class="box_head">
        <h3><?php echo $title; ?></h3>
    </div>


    <div id="produk_det">
        <div class="three columns alpha">
            <div class="mini_images">
                <a href="#"> <img src="<?php echo $gambar1 ?>" width="110" id='1' /> </a>
                <?php if ($list_produk->image2 != "") { ?>
                    <a href="#"> <img src="<?php echo $gambar2 ?>" width="110" id='2' /> </a>
                    <?php
                }
                if ($list_produk->image3 != "") {
                    ?>
                    <a href="#"> <img src="<?php echo $gambar3 ?>" width="110" id='3' /> </a>
                <?php }
                ?>
            </div>
        </div>


        <a href="#"> <img class="five columns alpha omega" src="<?php echo $gambar11 ?>" width="410"  id='11' /> </a>
        <a href="#"> <img class="nine columns alpha omega" src="<?php echo $gambar22 ?>" width="410" style='display: none;'  id='22' /> </a>
        <a href="#"> <img class="nine columns alpha omega" src="<?php echo $gambar33 ?>" width="410" style='display: none;'  id='33' /> </a>


        <div class="clear"></div> <br/>

        <div class="seven columns alpha">
            <div class="box_head">
                <h3>Info Produk</h3>
            </div>
            <table width = "100%">
                <tr>
                    <td width = "30%">Kode Produk</td>
                    <td>:</td>
                    <td><?php echo $id_produk ?> </td>
                </tr>
                <tr>
                    <td width = "30%">Nama Produk</td>
                    <td>:</td>
                    <td><?php echo $nama_produk ?></td>
                </tr>
                <tr>
                    <td width = "30%">Warna </td>
                    <td>:</td>
                    <td><?php echo $warna ?> </td>
                </tr>
                <tr>
                    <td width = "30%">Disk </td>
                    <td>:</td>
                    <td><?php echo $disk ?> %</td>
                </tr>
                <tr>
                    <td width = "30%">Harga</td>
                    <td>:</td>
                    <td><?php echo $harga ?></td>
                </tr>
                <tr>
                    <td width = "30%"><p>Stok </p> </td>
                    <td><p> : </p> </td>
                    <td><p  id="stok"> (Tentukan Pilihan terlebih dulu)</p> </td>
                </tr>
            </table>
        </div>

        <div class = "five columns omega" >
            <div class="box_head">
                <h3>Pilih Pemesanan</h3>
            </div>
            <?php
            $atr = array('id' => 'formID',
                'class' => 'formular');
            echo form_open('main/keranjang/add_item', $atr);
            ?>
            <label>Pilihan  Item :  </label>    
            <div class = "clear"></div>
            <select  name="produk_dett" id="produk_dett" class="validate[required] text-input">
                <?php
                echo "<option value='' >Pilihan :</option>";
                foreach ($list_pruduk_det as $dta) {
                    echo "<option value='$dta->id'>$dta->size_produk</option>";
                }
                ?>
            </select>
            <div class = "clear"></div>
            <label>Jumlah : </label>
            <div class = "clear"></div>
            <input type="text" size="5" name="bnyk" id="bnyk" autocomplete="off" class="validate[required,custom[integer], min[1]] text-input"/>
            <br/>
            <input class="red_btn" type = "submit" value = "Tambah Pemesanan"/>
            <div class="fb-like" data-href="http://grosirbadjoe.com/main/produk/produk_det/<?php echo $id_produk; ?>" data-send="false" data-layout="button_count" data-width="200" data-show-faces="true"></div>
            </form>
        </div>

        <div class = "clear"></div><br/>

        <div class="twelve columns alpha omega">
            <div class="box_head">
                <h3>Keterangan Produk</h3>
            </div>
            <?php echo $keterangan; ?> 
        </div>
        <div class = "clear"></div>
        <br/>
        <div class="twelve columns alpha omega">
            <div class="box_head">
                <h3>Komentar</h3>
            </div>
            <div class="fb-comments" data-href="http://grosirbadjoe.com/main/produk/produk_det/<?php echo $id_produk; ?>" data-num-posts="5" data-width="700" ></div>
            <div class="clear"></div>
        </div>
        <div class = "clear"></div>
        <br/>
    </div>

</div>


    <div id="fb-root"></div>
    <script>(function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/id_ID/all.js#xfbml=1";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
    </script>